#ifndef CRYPTOGRAPHY_H
#define CRYPTOGRAPHY_H

#include <QtCore>

#include <cryptopp/rsa.h>
#include <cryptopp/osrng.h>
#include <cryptopp/files.h>
#include <cryptopp/hex.h>
#include <cryptopp/oaep.h>
#include <cryptopp/pssr.h>
#include <cryptopp/hmac.h>

#include <iostream>
#include <string>

using namespace std;
using namespace CryptoPP;

class cryptography
{

public:
// Variables y objetos
    // variables que contienen los nombres de las llaves publicas del key generator y ballot generator respectivamente
    QString KG;
    QString BG;
    AutoSeededRandomPool Random;

// Funciones

    cryptography();
    void create_key(QString key_name);
    bool M1(QString PVID, QString &m1);
    bool M5(QString &m5, QString &B);
    bool M6(QString vote, QString PVID1, QString PVID2, QString &m6);

    QString Hash(QString B, QString keyname);
    QString HashKeys(QString keyname1, QString keyname2);
    bool Key2Hex(QString keyname,QString &keyHex);
    bool Hex2Key(QString keydata, QString keyname);

    QString PVID_generation(QString Data,QString Key);

    QString Hash(QString data);
    QString encryptMsg(QString Data,QString keyName);

private:

    AutoSeededRandomPool rng;
    void SavePrivateKey(QString filename, const PrivateKey& key);
    void SavePublicKey(QString filename, const PublicKey& key);
    void Save(QString filename, const BufferedTransformation& bt);
    void LoadPrivateKey(QString filename, PrivateKey& key);
    void LoadPublicKey(QString filename, PublicKey& key);
    void Load(QString filename, BufferedTransformation& bt);


    QString shift_String(QString &msg);
    QString shift_String(QString &msg,int max);


    bool decryptMsg(QString Data,QString keyName, QString &decryptedMsg);




    bool verifyMsg(QString msg,QString keyToUse, QString &verifiedMsg);


};

#endif // CRYPTOGRAPHY_H
